Modelling of a bull spread using Python

Overview:

  • A bull spread is an option strategy employed by the investors when they think that the market is going to behave bullish in the near term.
  • A bull spread involves the following actions:
  1. Buying of a European Call Option with a specific strike price K1
  2. Selling of a European Call Option with a strike price higher than K1
  • When the stock price moves above K1 and beyond K2 the investor makes limited profit.
  • When the stock price is below K1 the investor makes zero profit. There will not be any loss as well.

 

Example: Modeling of a Bull Spread using Python

# Python example

St          = 4500; #Initial stock price

K1          = 4600; #Buying out of money call

K2          = 4700; #Selling out of money call

 

print("K1:%2.f"%K1);

print("K2:%2.f"%K2);

 

# Stock price goes upwards

i = 0

while i < 5:

    St = St + 50

    payoff = 0

    if (St>K1 and St<K2):

        payoff      = St-K1;

    elif (St >= K2):

        payoff      = K2-K1;

    elif (St <= K1):

        payoff  = 0;

    else:

        payoff  = 0;        

       

    print("Stock price:%2.2f"%St);

    print("Payoff from bull spread:%2.2f"%payoff);

    print("-")

   

    i = i + 1;

 

# Stock price goes downwards

St          = 4500; #Initial stock price   

i = 0

while i < 5:

    St = St - 50

    payoff = 0

    if(St>K1 and St<K2):

        payoff      = St-K1;

        print("x");

    elif (St >= K2):

        payoff      = K2-K1;

        print("y");

    elif (St <= K1):

        payoff  = 0;

    else:

        payoff  = 0;

 

    print("Stock price:%2.2f"%St);

    print("Payoff from bull spread:%2.2f"%payoff);

    print("-")

    i = i + 1;

 

Output:

K1:4600

K2:4700

Stock price:4550.00

Payoff from bull spread:0.00

-

Stock price:4600.00

Payoff from bull spread:0.00

-

Stock price:4650.00

Payoff from bull spread:50.00

-

Stock price:4700.00

Payoff from bull spread:100.00

-

Stock price:4750.00

Payoff from bull spread:100.00

-

Stock price:4450.00

Payoff from bull spread:0.00

-

Stock price:4400.00

Payoff from bull spread:0.00

-

Stock price:4350.00

Payoff from bull spread:0.00

-

Stock price:4300.00

Payoff from bull spread:0.00

-

Stock price:4250.00

Payoff from bull spread:0.00

-

 


Copyright 2024 © pythontic.com